<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>物料信息</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<jsp:include page="${pageContext.request.contextPath }/resource_path.jsp" flush="true"/>
	<link rel="stylesheet" media="all" href="${pageContext.request.contextPath }/assets/formSelects/formSelects-v4.css">
	<link rel="stylesheet" media="all" href="${pageContext.request.contextPath }/assets/formSelects/formSelects-v4.js">
	<style type="text/css">
		.tmdyTable td{border:1px solid #00000080;} 
		.tmdyTable td input{
			width:100%;
			height:100%;
			border:0px;
			padding:0px;
			margin:0px;
		}
	</style>
</head>
<body class="layui-anim layui-anim-up">
<div class="x-nav">
    <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a>
            <cite>物料信息</cite>
        </a>
    </span>
</div>
<div class="x-body">
	<div class="layui-row">
		<form class="layui-form layui-col-md12 x-so" onsubmit="return false">
			<!-- <input type="text" name="keyword1" id="keyword1" placeholder="请输入姓名" autocomplete="off" class="layui-input">
			 -->
			      <div style="width:150px; float: left;">
		                                        <select id="keyword" name="keyword" lay-verify="keyword">
		                                            <option value="">请选择仓库名称</option>
		                                        </select>
		                                    </div>
		                                       <input type="hidden" id="dateTime">

            <div class="layui-input-inline" style="width: 150px">
                <input class="layui-input" id="date2"  style="width: 150px">
            </div>
			<button class="layui-btn layui-btn-normal" data-type="reload"><i class="layui-icon layui-icon-search"></i>检索</button>
		</form>
	</div>
	<xblock>
<button class="layui-btn layui-btn-danger" id="import"><i class="layui-icon layui-icon-download-circle"></i>导入</button>
		<button class="layui-btn layui-btn-danger" id="del"><i class="layui-icon layui-icon-delete"></i>批量删除</button>
		
		
	</xblock>
	<table class="layui-hide" id="staffList" lay-filter="staffList"></table>
	<script type="text/html" id="rowToolbar">
		<a class="layui-btn layui-btn-xs" lay-event="update"><i class="layui-icon layui-icon-edit"></i>编辑</a>
		<%--<a class="layui-btn layui-btn-xs" lay-event="bindingCustomer"><i class="layui-icon layui-icon-edit"></i>绑定客户</a>--%>
		<%--<a class="layui-btn layui-btn-xs" lay-event="bindingWarehouse"><i class="layui-icon layui-icon-edit"></i>绑定仓库</a>--%>
	</script>
	<div id="formDiv" hidden="hidden">
		<div class="box">
			<form class="layui-form layui-card-body" id="addform">
				<input hidden id="id" name="id">
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">客户</label>
						<div class="layui-input-inline" style="width: 285px">
							<select style="width: 285px" class="" name="client" id="client" lay-filter="client" xm-select="select1">
								<c:forEach items="${customerList }" var="c">
									<option value="${c.id }">${c.customer_name }</option>
								</c:forEach>
							</select>
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn  layui-btn-blue" lay-submit lay-filter="addform" id="subform">确定</button>
						<button class="layui-btn layui-btn-primary" style="margin-left:120px">取消</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<%--导入模板--%>
	<div class="modal fade" id="importDiv" hidden="hidden" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-body">
					<div style="text-align: center; padding: 5px">
						<a href="${pageContext.request.contextPath }/exceltemplate/artificial.xls">
							<img alt="导入人工信息-模板" src="${pageContext.request.contextPath }/images/excel_alt_1.png" style="width: 20px;"/>
							<span style="font-size: 15px; font-weight:200;color:red">artificial-模板.xls</span>
						</a>
					</div>
					<form id="importForm" class="layui-form" enctype="multipart/form-data">
						<div title="Excel导入操作" style="margin-left: 105px; padding: 5px">

							<input id="file" name="file" type="file" style="margin-bottom: 20px" accept=".xls,.xlsx"/>
						</div>
					</form>
					<div align="center">
						<button class="layui-btn layui-btn-blue" onclick="uploadBtn()">导入</button>
						&emsp;&emsp;
						<button class="layui-btn layui-btn-primary" onclick="qx()">取消</button>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div id="formDiv2" hidden="hidden">
		<div class="box">
			<form class="layui-form layui-card-body" id="addform2">
				<input hidden="hidden" id="id2" name="id">
				<!-- _______________________________________________ -->
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">客户</label>
						<div class="layui-input-inline" style="width: 285px">
							<select style="width: 285px" class="" name="remark" id="client2" lay-filter="client2" xm-select="select1">
								<c:forEach items="${customerList }" var="c">
									<option value="${c.id }">${c.customer_name }</option>
								</c:forEach>
							</select>
						</div>
					</div>
				</div>
				<!-- _______________________________________________ -->
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">仓库</label>
						<div class="layui-input-inline" style="width: 285px">
							<select style="width: 285px" class="" name="ware" id="ware" lay-filter="ware" xm-select="select2"></select>
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn  layui-btn-blue" lay-submit lay-filter="addform2" id="subform2">确定</button>
						<button class="layui-btn layui-btn-primary" style="margin-left:120px">取消</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<!-- 打印标签信息输入 -->
	<div id="dyXXDivID" hidden="hidden">
		<form class="layui-form layui-card-body">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">批次号</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" id="dy_pch" style="width: 300px">
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">包装数量</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" id="dy_bznum" style="width: 300px">
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">标签数量</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" id="dy_num" style="width: 300px">
					</div>
				</div>
			</div>
		</form>
		<xblock>
			<div align="right" style="margin-bottom: 0px;">
				<button type="button" id="dytm" class="layui-btn" style="margin-left: 400px;background-color: #57575799;"><i class="layui-icon">&#xe66e;</i>打印</button>
			</div>
		</xblock>
	</div>
	<!-- 打印标签框 -->
	<div id="dytmDivID" hidden="hidden">
		<div id="tmdyDiv" style="width: 100%;overflow-y:scroll;height: 499px">
		</div>
		<xblock>
			<div align="right" style="margin-bottom: 0px;">
				<button type="button" id="dayingTmdyTable" class="layui-btn" style="margin-left: 450px;background-color: #57575799;"><i class="layui-icon">&#xe66e;</i>打印</button>
			</div>
		</xblock>
	</div>
	<script type="text/javascript">
	   $(document).ready(function () {
	        var time = new Date();
	        var day = ("0" + time.getDate()).slice(-2);
	        var month = ("0" + (time.getMonth() + 1)).slice(-2);
	        var today = time.getFullYear() + "-" + (month);
	        $('#dateTime').val(today);
	    })
        var opts  = document.getElementById("client");
        function check(id){
            for(var i = 0;i<opts.options.length;i++){
                if(opts.options[i].value == id){
                    opts.options[i].setAttribute("selected", "selected");
                }
            }
        }
        //全局定义一次, 加载formSelects
        layui.config({
            base: '${pageContext.request.contextPath }/assets/formSelects/' //此处路径请自行处理, 可以使用绝对路径
        }).extend({
            formSelects: 'formSelects-v4'
        });
        layui.use(['table','layer','upload','form','laydate','formSelects'], function(){
            var table = layui.table;
            var layer = layui.layer;
            var form = layui.form;
            var laydate = layui.laydate;
            laydate.render({
                elem: '#date2',
                type: 'month',
                value: new Date(),
                done:function(value, date, endDate) {
                    $('#dateTime').val(value);
                }
            });
            var formSelects = layui.formSelects;
            var $ = layui.jquery, active = {
                reload:function () {
                	 var dateTime = $('#dateTime').val()
                     if (dateTime.length < 4) {
                         var time = new Date();
                         var day = ("0" + time.getDate()).slice(-2);
                         var month = ("0" + (time.getMonth() + 1)).slice(-2);
                         var today = time.getFullYear() + "-" + (month);
                         dateTime = today;
                     }
                    var keyword01 = $("#keyword1").val();
                    
                    table.reload('contenttable',{
                        method:'get',
                        where:{"uname":keyword01,'date':dateTime}
	                    ,page: {
		                    curr: 1//重新从第 1 页开始
		                }
                    });
                }
            }

            $('.layui-btn').on('click', function(){
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
            table.render({
                elem: '#staffList'
                ,url:'${pageContext.request.contextPath }/artificial/findArtificial.do'
                ,title: '人工列表'
                ,where:{'uname':null,'date':$('#dateTime').val()}
                ,id :'contenttable'
                ,limits:[10,20,30]
                ,toolbar: '#toolbar'
                	,totalRow: true
                ,cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    ,{field:'remark', title:'序号', sort: true, type:'numbers', width: 60, align:'center', unresize: true, sort: true, totalRowText: '合计'}
                    ,{field:'warename', title:'仓库', width: 90, align:'center'}
                    ,{field:'uname', title:'姓名', width: 110, align:'center'}

                    ,{field:'jobnum', title:'工号', width: 90, align:'center'}
                    ,{field:'pname', title:'岗位', width: 90, align:'center'}
                    ,{field:'basesalary', title:'底薪', width: 90, align:'center', sort: true, totalRow: true}
                    ,{field:'achievement', title:'绩效', width: 140, align:'center', sort: true, totalRow: true}
                    ,{field:'house', title:'住房补贴', width: 140, align:'center', sort: true, totalRow: true}
                    ,{field:'traffic', title:'交通补贴', width: 140, align:'center', sort: true, totalRow: true}
                    ,{field:'skill', title:'技能补贴', width: 80, align:'center', sort: true, totalRow: true}
                    ,{field:'communication', title:'通讯补贴', width: 90, align:'center', sort: true, totalRow: true}
                    ,{field:'oilpatch', title:'油补', width: 100, align:'center', sort: true, totalRow: true}
                    ,{field:'ageaward', title:'工龄奖', width: 100, align:'center'}
                    ,{field:'hightemperature', title:'高温补贴', width: 120, align:'center', sort: true, totalRow: true}
                     ,{field:'benefit', title:'其他福利', width: 80, align:'center', sort: true, totalRow: true}
                    ,{field:'meal', title:'餐补', width: 80, align:'center', sort: true, totalRow: true}
                    ,{field:'overtimepay', title:'加班费', width: 90, align:'center', sort: true, totalRow: true}
                    ,{field:'pincometax', title:'个税', width: 90, align:'center', sort: true, totalRow: true}
                    ,{field:'deduction', title:'扣款', width: 90, align:'center', sort: true, totalRow: true}
                    ,{field:'service', title:'服务费', width: 90, align:'center', sort: true, totalRow: true}
                    ,{field:'sscompany', title:'社保公司', width: 80, sort: true, totalRow: true}
                    ,{field:'sume', title:'合计', width: 80, sort: true, totalRow: true}
                  	
                ]]
                ,page: true
                ,done : function(){
                    $('th').css({
                        'background-color': '#009688', 'color': '#fff','font-weight':'bold',
                    })
                }
            });

            //监听复选框事件
            table.on('checkbox(staffList)',function(obj){
                if(obj.checked == true && obj.type == 'all'){
                    //点击全选
                    $('.layui-table-body table.layui-table tbody tr').addClass('layui-table-click');
                }else if(obj.checked == false && obj.type == 'all'){
                    //点击全不选
                    $('.layui-table-body table.layui-table tbody tr').removeClass('layui-table-click');
                }else if(obj.checked == true && obj.type == 'one'){
                    //点击单行
                    if(obj.checked == true){
                        obj.tr.addClass('layui-table-click');
                    }else{
                        obj.tr.removeClass('layui-table-click');
                    }
                }else if(obj.checked == false && obj.type == 'one'){
                    //点击全选之后点击单行
                    if(obj.tr.hasClass('layui-table-click')){
                        obj.tr.removeClass('layui-table-click');
                    }
                }
            })

            /**
             * 表单校验
             */
            form.verify({
                //value：表单的值、item：表单的DOM对象
                customer_id: function(value, item){
                    if(value == ''){
                        return '供应商名称不能为空';
                    }
                },
                region_id: function(value, item){
                    if(value == ''){
                        return '库区名称不能为空';
                    }
                },
                container_id: function(value, item){
                    if(value == ''){
                        return '容器名称不能为空';
                    }
                },
                materiel_name: function(value, item){
                    if(value == ''){
                        return '中文名称不能为空';
                    }
                },
                materiel_num: function(value, item){
                    if(value == ''){
                        return 'SAP/QAD不能为空';
                    }
                },
                brevity_num: function(value, item){
                    if(value == ''){
                        return '简码不能为空';
                    }
                },
                is_check: function(value, item){
                    if(value == ''){
                        return '质检不能为空';
                    }
                },
                materiel_size: function(value, item){
                    if(value == ''){
                        return '物料规格不能为空';
                    }
                },
                materiel_properties: function(value, item){
                    if(value == ''){
                        return '物料型号不能为空';
                    }
                },
                out_date: function(value, item){
                    if(value == ''){
                        return '出厂日期不能为空';
                    }
                },
                delivery_address: function(value, item){
                    if(value == ''){
                        return '收货地址不能为空';
                    }
                },
                upper_value: function(value, item){
                    if(value == ''){
                        return '物料上限值不能为空';
                    }
                },
                lower_value: function(value, item){
                    if(value == ''){
                        return '物料下限值不能为空';
                    }
                },
                packing_quantity: function(value, item){
                    if(value == ''){
                        return '包装数量不能为空';
                    }
                },
                /*is_devanning: function(value, item){
                    if(value == ''){
                        return '包装数量不能为空';
                    }
                },
                removal_container: function(value, item){
                    if(value == ''){
                        return '拆箱后容器不能为空';
                    }
                },*/
                storage_type: function(value, item){
                    if(value == ''){
                        return '入库类型不能为空';
                    }
                },
                is_bindtray: function(value, item){
                    if(value == ''){
                        return '是否绑定托盘不能为空';
                    }
                },
                tray_type: function(value, item){
                    if(value == ''){
                        return '托盘类型不能为空';
                    }
                }
            });

          

            /*==============导出===============*/
            $("#export").click(function(){
            	var keyword01 = $("#keyword1").val();
                var keyword02 = $("#keyword2").val();
                var keyword03 = $("#keyword3").val();
                var keyword04 = $("#keyword4").val();
            	
                window.location.href="${pageContext.request.contextPath}/materiel/doExportall.do?keyword01="+keyword01+"&keyword02="+keyword02+"&keyword03="+keyword03+"&keyword04="+keyword04;
            })
            /*==============导入===============*/
            $("#import").click(function(){
                layer.open({
                    type: 1 					//Page层类型
                    ,area: ['380px', '200px'] 	//宽  高
                    ,title: '导入&nbsp;<span style="color: green">注：请点击红色链接下载模板</span>'
                    ,shade: 0.6 				//遮罩透明度
                    ,maxmin: true 				//允许全屏最小化
                    ,anim: 1 					//0-6的动画形式，-1不开启
                    ,content:$('#importDiv')
                });
            });

            //批量删除
            $("#del").click(function(){
                var rowData = table.checkStatus('contenttable');
                var data = rowData.data;
                var idArr = new Array();
                if(data.length == 0){
                    toastrStyle();
                    toastr.warning("请至少选择一条记录！");
                } else {
                    for(var i=0;i < data.length;i++){
                        idArr[i] = data[i].uid;
                    }
                    $.ajax({
                        type:'post',
                        url:'${pageContext.request.contextPath }/artificial/deleteArtificial.do',
                        data:{"idArr" : idArr},
                        success:function(data){
                            layer.confirm('确定删除吗？', function(){
                                if(data > 0){
                                    toastr.success("删除成功！");
                                    setTimeout(function(){
                                        location.reload();
                                    },1000);
                                    setTimeout(function(){
                                        window.location.reload();
                                    },2000);
                                }else{
                                    toastr.warning("删除失败！");
                                    location.reload();
                                }
                            });
                        }
                    });
                }
            });

            /**
             * 通用表单提交(AJAX方式)
             */
            form.on('submit(addForm)', function () {
                $.ajax({
                    type:'post',
                    url:'${pageContext.request.contextPath }/materiel/addMateriel.do',
                    data:$("#addFormID").serialize(),
                    cache:false,
                }).done(
                    function(res) {
                        if (res > 0) {
                            toastr.success('新增成功！');
                            setTimeout(function(){
                                location.reload();
                            },1000);
                        }
                    }
                ).fail(
                    function() {
                        toastr.error('新增失败！');
                        setTimeout(function(){
                            location.reload();
                        },1000);
                    }
                )
                return false;
            })
            form.on('submit(uplodeform)', function (data) {
                var fileName = $("#files").val();
                if (fileName.length > 0) {
                    var formData = new FormData($("#importForm")[0]);
                    $.ajax({
                        url: '${pageContext.request.contextPath}/materiel/uplodeFile.do' ,
                        type: 'post',
                        data: formData,

                        processData: false,
                        success: function (data) {
                            if (data == 1) {
                                toastr.success("文件导入成功！（客户名称重复的直接过滤）");
                                setTimeout(function() {//使用setTimeout()方法设定定时2000毫秒

                                },1000);
                            }else if(data == -1){
                                toastr.warning("导入的数据不符合导入条件（客户名称不能重复）！");
                            }else{
                                toastr.warning("文件格式异常，文件导入失败！");
                            }
                        },
                        error: function (data) {
                            toastr.error("文件格式异常，文件导入失败！");
                        }
                    });
                } else {
                    toastr.warning("上传文件为空，请选择要导入的文件！");
                }
            })
            /**
             * 通用表单编辑(AJAX方式)
             */
            form.on('submit(updateForm)', function () {
                $.ajax({
                    type : 'post',
                    url : '${pageContext.request.contextPath }/materiel/updateMateriel.do',
                    data : $("#updateFormID").serialize(),
                    cache : false,
                }).done(
                    function(res) {
                        if (res > 0) {
                            toastr.success('修改成功！');
                            setTimeout(function(){
                            	layer.closeAll();
                                //location.reload();
                            	var keyword01 = $("#keyword1").val();
                                var keyword02 = $("#keyword2").val();
                                var keyword03 = $("#keyword3").val();
                                var keyword04 = $("#keyword4").val();
                                table.reload('contenttable',{
                                    method:'get',
                                    where:{"keyword01":keyword01, "keyword02":keyword02, "keyword03":keyword03, "keyword04":keyword04}
	                                ,page: {
	        		                    curr: 1//重新从第 1 页开始
	        		                }
                                });
                            },1000);
                        }
                    }
                ).fail(
                    function() {
                        toastr.error('修改失败！');
                        setTimeout(function(){
                        	layer.closeAll();
                            //location.reload();
                        	var keyword01 = $("#keyword1").val();
                            var keyword02 = $("#keyword2").val();
                            var keyword03 = $("#keyword3").val();
                            var keyword04 = $("#keyword4").val();
                            table.reload('contenttable',{
                                method:'get',
                                where:{"keyword01":keyword01, "keyword02":keyword02, "keyword03":keyword03, "keyword04":keyword04}
	                            ,page: {
	    		                    curr: 1//重新从第 1 页开始
	    		                }
                            });
                        },1000);
                    }
                )
                return false;
            })
            //绑定客户
            form.on('submit(addform)', function (data) {
                $("#subform").attr("disabled",true);
                $.ajax({
                    url : '${pageContext.request.contextPath }/materiel/bindingCustomer.do',
                    data : $('#addform').serialize(),
                    type : "post",
                    //dataType : "json",
                }).done(
                    function(res) {
                        if(res>0){
                            toastr.success('绑定成功！');
                            setTimeout(function(){
                                location.reload();
                            },2000);
                        }
                    }
                )
                return false;
            });
            //绑定仓库
            form.on('submit(addform2)', function (data) {
                $("#subform2").attr("disabled",true);
                $.ajax({
                    url : '${pageContext.request.contextPath }/materiel/bindingWarehouse.do',
                    data : $('#addform2').serialize(),
                    type : "post",
                    //dataType : "json",
                }).done(
                    function(res) {
                        if(res>0){
                            toastr.success('绑定成功！');
                            setTimeout(function(){
                                location.reload();
                            },2000);
                        }else{
                            toastr.success('清空绑定！');
                            setTimeout(function(){
                                location.reload();
                            },2000);

                        }
                    }
                )
                return false;
            });
            
            //选择库区名称带回放置类型
            /* form.on('select(region_id)', function(data){
				$.ajax({
					type: 'POST',
					url: '${pageContext.request.contextPath}/materiel/queryRegionTypeById.do',
					data: {region_id:data.value},
					dataType: 'json',
					async: false,
					success: function (datas){
						if (datas[0].region_type == 0) {
							$("#placement_type").val("货架");
						} else if (datas[0].region_type == 1) {
							$("#placement_type").val("平地");
						} else {
							$("#placement_type").val("不良品");
						}
					}
				});
				form.render();
			}); */
			//打印标签信息录入
            $("#dybq").click(function(){
            	var checkStatus = table.checkStatus('contenttable')
                var datas = checkStatus.data;
                if(datas.length!=1){
                    toastr.warning("请选择一条记录！");
                }else{
                	var data = datas[0]
    	            layer.open({
    	                type: 1 					//Page层类型
    	                ,area: ['510px', ''] 			//宽  高
    	                ,title: '打印标签信息'
    	                ,shade: 0.6 				//遮罩透明度
    	                ,maxmin: true 				//允许全屏最小化
    	                ,anim: 1 					//0-6的动画形式，-1不开启
    	                ,content: $('#dyXXDivID')
    	                ,end: function () {
    	                    var formDiv = document.getElementById('dyXXDivID');
    	                    formDiv.style.display = '';
    	                }
    	                ,success: function(){
    	                	$("#dy_pch").val("")
    	                	$("#dy_bznum").val(data.packing_quantity)
    	                	$("#dy_num").val(1)
    	                }
    	            });
                }
            });
			
          //打印标签
            $("#dytm").click(function(){
            	var checkStatus = table.checkStatus('contenttable')
                var datas = checkStatus.data;
                if(datas.length!=1){
                    toastr.warning("请选择一条记录详情！");
                }else{
                	layer.closeAll();
               	  	var num = $.trim($("#dy_num").val());
               	  	var dy_bznum = $.trim($("#dy_bznum").val());
               	  	var dy_pch = $.trim($("#dy_pch").val());
               		var re = /^[1-9]\d*$/;
               	  	if(!re.test(num) || !re.test(dy_bznum)){
               	  		toastr.warning("请输入正整数！");
   	                }else{
   	            	  	var hight = '600px'
   	            	  	/* if(num > 2){
   		            	  	hight = '90%'
   	            	  	} */
   	            	  	var data = datas[0]
   	    	            layer.open({
   	    	                type: 1 					//Page层类型
   	    	                ,area: ['1200px', hight] 			//宽  高
   	    	                ,title: '打印标签'
   	    	                ,shade: 0.6 				//遮罩透明度
   	    	                ,maxmin: true 				//允许全屏最小化
   	    	                ,anim: 1 					//0-6的动画形式，-1不开启
   	    	                ,content: $('#dytmDivID')
   	    	                ,end: function () {
   	    	                    var formDiv = document.getElementById('dytmDivID');
   	    	                    formDiv.style.display = '';
   	    	                }
   	    	                ,success: function(){
   	    	                	var materiel_name = data.materiel_name;
   	    	                	var materiel_num = data.materiel_num;
   	    	                	var packing_quantity = data.packing_quantity;
   	    	                	var time = curentTime();
   	    	                	var pici = dy_pch;
   	    	                	var bznum = dy_bznum;
   	    	                	var customer_name = data.customer_name;
   	    	                	var tm = "";
   	    	                	var tmwmimg = '<%=request.getContextPath()%>/';
   	    	                	var tm2wmimg = "";
   	    	                	var tm1wmimg = "";
   	    	                	var code = new Array();
   	    	                	$.ajax({
   	                                type:'post',
   	                                data:'id='+data.id+"&num="+num,
   	                                url:'${pageContext.request.contextPath}/label/dyByMid.do',
   	                                dataType: 'JSON',
   	                                async: false,
   	                                success:function (data) {
   	                                	code = data.code;
   	                                }
   	                            });
   	    	                	
       	                		var html = '';
   	    	                	for (var i = 0; i < num; i++) {
   	    	                		tm = code[i][0];
                                   	tm2wmimg = tmwmimg+code[i][1];
                                   	tm1wmimg = tmwmimg+code[i][2];
                                   	
                                  //分页
                                    if(i == 0){
        	                            html += '<div class="A4">'
                                    /* }else{
        	                            if(i%6 == 0){
        		                            html += '</div>'
        		                            html += '<div class="A4">'
        	                            } */
                                    }
                                   	
                                   	
   	    	                		html += '<table class="tmdyTable" style="border: 2px solid #222;width: 540px;height: 260px;margin:0 auto;margin-bottom: 20px;display:inline-table;/*display:inline-block; float:left;*/margin-left: 48px;">'
   	    	                			html += '<tr>'
   	    	                				html += '<td width="100" align="center">'
   	    	                					html += '零件名称：'
   	    	                				html += '</td>'
   	    	                				html += '<td width="220">'
   	    	                				html += materiel_name
   	    	                				html += '</td>'
   	    	                				html += '<td rowspan="8" width="200">'
   	    	                					html += '<img src="'+tm2wmimg+'" width="100%" height="100%"/>'
   	    	                				html += '</td>'
   	    	                			html += '</tr>'
   	    	                			html += '<tr>'
   	    	                				html += '<td align="center">'
   	    	                					html += '零件号：'
   	    	                				html += '</td>'
   	    	                				html += '<td>'
   	    	                					html += materiel_num
   	    	                				html += '</td>'
   	    	                			html += '</tr>'
   	    	                			html += '<tr>'
   	    	                				html += '<td align="center">'
   	    	                					html += '供应商：'
   	    	                				html += '</td>'
   	    	                				html += '<td>'
   	    	                					html += customer_name
   	    	                				html += '</td>'
   	    	                			html += '</tr>'
   	    	                			html += '<tr>'
   	    	                				html += '<td align="center">'
   	    	                					html += '包装信息：'
   	    	                				html += '</td>'
   	    	                				html += '<td>'
   	    	                					html += packing_quantity
   	    	                				html += '</td>'
   	    	                			html += '</tr>'
   	    	                			html += '<tr>'
   	    	                				html += '<td align="center">'
   	    	                					html += '包装数量：'
   	    	                				html += '</td>'
   	    	                				html += '<td>'
   	    	                					html += bznum
   	    	                				html += '</td>'
   	    	                			html += '</tr>'
   	    	                			html += '<tr>'
   	    	                				html += '<td align="center">'
   	    	                					html += '日期时间：'
   	    	                				html += '</td>'
   	    	                				html += '<td>'
   	    	                					html += time
   	    	                				html += '</td>'
   	    	                			html += '</tr>'
   	    	                			html += '<tr>'
   	    	                				html += '<td align="center">'
   	    	                					html += '批次信息：'
   	    	                				html += '</td>'
   	    	                				html += '<td>'
   	    	                					html += pici
   	    	                				html += '</td>'
   	    	                			html += '</tr>'
   	    	                			html += '<tr>'
   	    	                				html += '<td align="center">'
   	    	                					html += '条码信息：'
   	    	                				html += '</td>'
   	    	                				html += '<td>'
   	    	                					html += tm
   	    	                				html += '</td>'
   	    	                			html += '</tr>'
   	    	                			html += '<tr>'
   	    	                				html += '<td colspan="3">'
   	    	                					html += '<img src="'+tm1wmimg+'" width="100%" height="50px" id="dpddremark_dy"/>'
   	    	                				html += '</td>'
   	    	                			html += '</tr>'
   	    	                			html += '<tr style="height:5px"></tr>'
   	    	                		html += '</table>'
   								}
   	    	                	
   	    	               		//分页
   	    	                	html += '</div>'
   	    	                	
   	    	                	var tmdyDiv = document.getElementById("tmdyDiv");
       	                		tmdyDiv.innerHTML= html;
   	    	                }
   	    	            });
   	                } 
                }
            });
            $("#dayingTmdyTable").click(function(){
            	//layer.closeAll();
    		    var obj =document.getElementById('tmdyDiv')
    			var css='<style>'
    				+".A4 {page-break-before: auto;page-break-after: always;}"
                    +".tmdyTable td{border:1px solid #00000080;}"
                    +'.tmdyTable td input{width:100%;height:100%;border:0px;padding:0px;margin:0px;}'
                    +'.tmdyTable{border:1px solid #F00;border-collapse:collapse;}'
                    +'.tmdyTable td{border:1px solid #222;}'
                    +'</style>'; 
    			var docStr =  css+ obj.innerHTML;
    			var newWindow=window.open("打印窗口","_blank");//打印窗口要换成页面的url
    			newWindow.document.write(docStr);
    		    newWindow.document.close();
    		    newWindow.print(); 
    		    //newWindow.close(); 
    		    printpage(docStr)
    		});
          	//获取当前时间
            function curentTime() {
                var now=new Date();
                var year = now.getFullYear();       //年
                var month = now.getMonth() + 1;     //月
                var day = now.getDate();            //日
                var time=year+"-"+add0(month)+"-"+add0(day);
                return time;
            }
            
            function add0(m){
                return m<10?'0'+m:m
            }
        });
        
        toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上
        
        //日期格式转换
        function dateToStr(date) {
            var time = new Date(date.time);
            var y = time.getFullYear();
            var M = time.getMonth() + 1;
            M = M < 10 ? ("0" + M) : M;
            var d = time.getDate();
            d = d < 10 ? ("0" + d) : d;
            var str = y + "-" + M + "-" + d;
            return str;
        }
        function qx(){

            location.reload();
        }
        function uploadBtn() {
            var fileName = $("#file").val();
            var formData = new FormData($("#importForm")[0]);

            $.ajax({
                url: '${pageContext.request.contextPath}/artificial/uplodeFile.do' ,
                type: 'post',
                data: formData,
                async: false,
                cache: false,
                contentType: false,
                processData: false,
                success: function (data) {
                    if (data == 1) {
                        toastr.success("文件导入成功！");
                        setTimeout(function() {//使用setTimeout()方法设定定时2000毫秒
                            location.reload();
                        },1000);
                    }else if(data == -1){
                        toastr.warning("导入的数据不符合导入条件！");
                    }else{
                        toastr.warning("文件格式异常，文件导入失败！");
                    }
                },
                error: function (data) {
                    toastr.error("文件格式异常，文件导入失败！");
                }
            });

        }
        $(document).ready(function(){
        	
            $.ajax({
                type: 'POST',
                url: '${pageContext.request.contextPath}/warehouse/queryAllWarehouse.do',
                dataType: 'json',
                async: false,
                success: function (datas){
                    for (var i = 0; i < datas.length; i++) {
                        $("#keyword").append("<option value='"+ datas[i].id +"'>"+ datas[i].warehouse_name +"</option>");
                    }
                }
            });
            })
	</script>
</body>
</html>